﻿//===============================================================================
//	CAskMissionList
//	请求任务列表
//===============================================================================

#include "CAskMissionList.h"
#include "../share/user_define.h"


//-------------------------------------------------------------------------------
CAskMissionList::CAskMissionList(uint32_t uid, uint32_t pn)
	: BaseMessage(uid, pn)
{
	_safe_guard_begin;
	_safe_guard_end;
}

//-------------------------------------------------------------------------------
CAskMissionList::~CAskMissionList(void)
{

}

//-------------------------------------------------------------------------------
void CAskMissionList::SetMissionListData(MissionSystem * MissionData)
{
	_safe_guard_begin;

	/*临时：屏蔽主线任务*/
	//m_jv["ret"] = 1;
	//m_jv["ret"] = 0;

	//Json::Value jv1;
	//Json::Value jv21;
	//jv21.clear();

	//jv1.append(0);	//任务id
	//jv1.append(0);	//任务info_1--当前状态
	//jv1.append(0);	//任务info_2--达成次数

	//jv21.append(jv1);

	//m_jv["misinfo"] = jv21;

	////m_jv["desc"] = "主线功能维护中...请见谅.";

	//std::string str = JsonWriter(m_jv);

	//return;
	/*!*/

	Json::Value jv;
	Json::Value jv2;
	jv2.clear();
	//! for (uint32_t i = 0; i < MissionSystem::GetMissionCount(); i++)全部任务大列表
	for (uint32_t i = 0; i < 1; ++i )//调整为只有一个主线任务
	{
		jv.clear();
		mission* p = MissionData->GetMissionInfoByIndex(i);
		if (nullptr == p)
		{
			continue;
		}
		_safe_check(p);

		uint32_t idx = i;
		jv.append(idx);//idx
		jv.append(p->m_mission_id);
		jv.append(p->m_scrip_id);
		jv.append(p->m_is_available);
		jv.append(p->m_info.GetValue(0));//任务0：step
		jv.append(p->m_info.GetValue(1));//任务0：目标count_1
		jv.append(p->m_info.GetValue(2));//任务0：目标count_2
		jv.append(p->m_info.GetValue(3));//任务0：预留
		jv.append(p->m_npc_id);
		jv.append(p->m_type);

		jv2.append(jv);
	}

	m_jv["misinfo"] = jv2;
	m_jv["ret"] = 0;

	_safe_guard_end;
}
